package com.example.demo.controller;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.entity.AddressInBean;
import com.example.demo.entity.AddressOutBean;
import com.example.demo.entity.UserInBean;
import com.example.demo.entity.UserOutBean;
import com.example.demo.service.UserService;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;


@RestController
@RequestMapping("api/user")
public class UserController {
	@Autowired
	private UserService userService;
	
	@ApiOperation(value="获取用户信息",httpMethod="POST",notes="获取用户信息",consumes="application/json",produces="application/json")
	@ApiImplicitParam(name="request",value="getUser",required=true,dataType="UserInBean")
	@RequestMapping("/getUser")
	public UserOutBean getUser(@RequestBody UserInBean request){
		UserOutBean response=new UserOutBean();
		AddressInBean inBean=new AddressInBean();
		inBean.setAddressId(request.getPassword());
		AddressOutBean outBean=userService.getAddress(inBean);
		response.setUserName(request.getUserName());
		response.setAddressDetail(outBean.getAddressDetail());
		return response;
	}

}
